package com.keba.lamp.complaint.manager.impl;

import com.keba.basic.base.manager.impl.SuperManagerImpl;
import com.keba.basic.database.mybatis.conditions.Wraps;
import com.keba.basic.database.mybatis.conditions.query.LbQueryWrap;
import com.keba.lamp.complaint.entity.EvidenceCaseRel;
import com.keba.lamp.complaint.manager.EvidenceCaseRelManager;
import com.keba.lamp.complaint.mapper.EvidenceCaseRelMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 通用业务实现类
 * 证据目录和案件关联表
 * </p>
 *
 * @author chaowu.wang
 * @date 2025-04-02 00:12:46
 * @create [2025-04-02 00:12:46] [chaowu.wang] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class EvidenceCaseRelManagerImpl extends SuperManagerImpl<EvidenceCaseRelMapper, EvidenceCaseRel> implements EvidenceCaseRelManager {


    @Override
    public boolean deleteByCaseId(Long caseId, Long tenantId) {
        LbQueryWrap<EvidenceCaseRel> queryWrap = Wraps.<EvidenceCaseRel>lbQ()
                .eq(EvidenceCaseRel::getCaseId, caseId)
                .eq(EvidenceCaseRel::getTenantId, tenantId);
        return this.remove(queryWrap);
    }

    @Override
    public boolean deleteByCaseIds(List<Long> caseIds) {
        LbQueryWrap<EvidenceCaseRel> queryWrap = Wraps.<EvidenceCaseRel>lbQ()
                .in(EvidenceCaseRel::getCaseId, caseIds);
        return this.remove(queryWrap);
    }

    @Override
    public boolean deleteByBizTypeAndCaseType(Long caseId, String bizType, String caseType, Long tenantId) {
        LbQueryWrap<EvidenceCaseRel> queryWrap = Wraps.<EvidenceCaseRel>lbQ()
                .eq(EvidenceCaseRel::getCaseId, caseId)
                .eq(EvidenceCaseRel::getBizType, bizType)
                .eq(EvidenceCaseRel::getCaseType, caseType)
                .eq(EvidenceCaseRel::getTenantId, tenantId);
//        List<EvidenceCaseRel> list = this.list(queryWrap);
//        if (CollectionUtil.isNotEmpty(list)) {
//            List<Long> idList = list.stream().map(EvidenceCaseRel::getId).collect(Collectors.toList());
//            this.removeByIds(idList);
//
//
//        }
        boolean result = this.remove(queryWrap);
        return result;
    }

    @Override
    public List<EvidenceCaseRel> listByCaseId(Long caseId, String bizType, String caseType) {
        LbQueryWrap<EvidenceCaseRel> queryWrap = Wraps.<EvidenceCaseRel>lbQ()
                .eq(EvidenceCaseRel::getCaseId, caseId)
                .eq(EvidenceCaseRel::getBizType, bizType)
                .eq(EvidenceCaseRel::getCaseType, caseType);
        return this.list(queryWrap);
    }
}


